
    <!DOCTYPE html>
    <html lang="zh-CN">
    <head>
      <meta charset="UTF-8">
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <title>如何在Docker环境中部署Zookeeper集群？ - 学习卡片</title>
      <style>
        body { font-family: sans-serif; background-color: #f0f8ff; color: #333; display: flex; flex-direction: column; align-items: center; padding: 50px 20px; }
        .header h1 { font-size: 32px; }
        .grid-container { display: grid; grid-template-columns: repeat(3, 1fr); gap: 28px; width: 100%; max-width: 1200px; }
        .card-container { perspective: 1200px; cursor: pointer; height: 250px; }
        .card { width: 100%; height: 100%; position: relative; transform-style: preserve-3d; transition: transform 0.7s; border-radius: 16px; box-shadow: 0 4px 16px rgba(0,0,0,0.08); }
        .card-container.flipped .card { transform: rotateY(180deg); }
        .card-face { position: absolute; width: 100%; height: 100%; backface-visibility: hidden; display: flex; flex-direction: column; box-sizing: border-box; border-radius: 16px; background-color: #fff; padding: 24px; }
        .card-back { background-color: #f0fff4; transform: rotateY(180deg); justify-content: space-between; }
        .card-category { font-size: 14px; color: #0052d9; margin-bottom: 8px; font-weight: 500; }
        .card-question { font-size: 20px; font-weight: 500; flex-grow: 1; display: flex; align-items: center; justify-content: center; text-align: center; }
        .card-answer-wrapper { flex-grow: 1; overflow-y: auto; }
        .card-answer { font-size: 15px; line-height: 1.7; }
        .card-footer { font-size: 13px; color: #8a919f; border-top: 1px solid #f0f0f0; padding-top: 16px; margin-top: 16px; }
        .card-source { font-size: 13px; color: #8a919f; border-top: 1px solid #f0f0f0; padding-top: 12px; margin-top: 12px; }
      </style>
    </head>
    <body>
      <div class="header">
        <h1>如何在Docker环境中部署Zookeeper集群？ - 学习卡片</h1>
      </div>
      <div class="grid-container">
        
    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">技术</div>
          <div class="card-question">在使用 Docker 部署 Zookeeper 集群时，为了确保实例间的网络通信，首要步骤是什么？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">技术</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">首要步骤是创建一个自定义的 Docker 网络，以确保所有 Zookeeper 实例能够正常通信。具体命令为 `docker network create zookeeper-network`。</div>
          </div>
          <div class="card-source">来源: 部署步骤 -> 创建 Docker 网络</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">配置</div>
          <div class="card-question">在 Zookeeper 的 Docker Compose 配置中，`ZOO_MY_ID` 和 `ZOO_SERVERS` 这两个环境变量分别有什么作用？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">配置</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">`ZOO_MY_ID` 用于为每个 Zookeeper 实例指定一个唯一的ID。`ZOO_SERVERS` 则用于定义集群中所有服务器的列表，以便节点之间可以相互发现和通信。</div>
          </div>
          <div class="card-source">来源: 部署步骤 -> 配置 Zookeeper 容器</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">技术</div>
          <div class="card-question">启动 Zookeeper 集群后，如何验证其运行状态？请描述具体命令。</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">技术</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">可以通过访问 Zookeeper 的客户端工具进行验证。首先使用 `docker exec -it zookeeper1 zkCli.sh` 进入客户端，然后在客户端中执行 `stat` 命令来检查集群状态。</div>
          </div>
          <div class="card-source">来源: 部署步骤 -> 验证集群状态</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">机制</div>
          <div class="card-question">如何为 Zookeeper Docker 容器配置数据持久化以避免数据丢失？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">机制</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">通过使用 Docker 的数据卷（volumes）功能，将 Zookeeper 容器内的数据目录（如 `/data` 和 `/datalog`）映射到主机的物理路径上，从而实现数据持久化。</div>
          </div>
          <div class="card-source">来源: 最佳实践 -> 数据持久化</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">模式</div>
          <div class="card-question">为了实现 Zookeeper 集群的高可用性，关于节点数量有什么最佳实践建议？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">模式</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">建议至少使用奇数个节点（如3个或5个），这样做的目的是为了在发生节点故障时，集群仍能维持多数节点的选举机制，从而保证高可用性。</div>
          </div>
          <div class="card-source">来源: 最佳实践 -> 高可用性</div>
        </div>
      </div>
    </div>

    <div class="card-container" onclick="this.classList.toggle('flipped');">
      <div class="card">
        <div class="card-face card-front">
          <div class="card-category">配置</div>
          <div class="card-question">在 `docker-compose.yml` 文件中，如何为 Zookeeper 容器设置资源限制以防止其消耗过多系统资源？</div>
          <div class="card-footer">点击卡片查看答案</div>
        </div>
        <div class="card-face card-back">
          <div class="card-category">配置</div>
          <div class="card-answer-wrapper">
            <div class="card-answer">可以在服务的 `deploy` 配置下设置 `resources` 限制。例如，可以设置 CPU 和内存的上限：`deploy: resources: limits: { cpus: "0.5", memory: "512M" }`。</div>
          </div>
          <div class="card-source">来源: 最佳实践 -> 资源限制</div>
        </div>
      </div>
    </div>

      </div>
    </body>
    </html>
